package office.dao.sale;

import java.util.Iterator;
import java.util.Map;

import platform.common.dao.impl.BaseDomainProviderImpl;

public class CustomerDP extends BaseDomainProviderImpl{
	
	//方法描述: 根据项目名称获取标书信息
	public String findCustomerByIdAndName(Map condMap){
		StringBuffer strBuf = new StringBuffer();
		strBuf.append(" from "+ this.getDomainClassName() + " where 1=1 ");
		Iterator it = condMap.keySet().iterator();
		while(it.hasNext()){
			String str = (String)it.next();
			if(str.equals("name")){
				strBuf.append(" and name like '%"+condMap.get(str)+"%' ");
			}
			if(str.equals("writeMan")){
				strBuf.append(" and (writeMan = '"+condMap.get(str)+"' or salesMan = '"+condMap.get(str)+"')");
			}
		}
		return strBuf.toString();
	}
	//方法描述: 根据标书状态获取标书
	public String findAllCustomer(Map condMap){
		StringBuffer strBuf = new StringBuffer();
		strBuf.append(" from "+ this.getDomainClassName() + " where 1=1 ");
		if(condMap != null){
			Iterator it = condMap.keySet().iterator();
			while(it.hasNext()){
				String str = (String)it.next();
				if(str.equals("writeMan")){
					strBuf.append(" and (writeMan = '"+condMap.get(str)+"' or salesMan = '"+condMap.get(str)+"')");
				}
			}
		}
		return strBuf.toString();
	}
	
	public String getDeleteCustomerInfoByCustomerId(){
		String hql = "delete from CustomerInfo where customer.id=:customerId";
		return hql;
	}
}
